package xyz.example.reflect;

import org.junit.Test;
import xyz.lwm.lazycat.utility.reflect.ReflectUtil;

import java.lang.reflect.Field;
import java.util.Map;

public class ReflectTest {

    @Test
    public void test() {
        Map<String, Field> fields = ReflectUtil.findDeclaredFields(SimpleBean.class);
        fields.forEach((name, field) -> {
            System.out.println(name + ":" + field.getType().getName());
        });
        SimpleBean bean = new SimpleBean();
        ReflectUtil.setValue(bean, "id", 1L);
        ReflectUtil.setValue(bean, "name", "lazycat");
        ReflectUtil.setValue(bean, "age", 18);
        ReflectUtil.setValue(bean, "sex", true);
        ReflectUtil.setValue(bean, "score", 90.0);
        ReflectUtil.setValue(bean, "height", 1.8f);
        System.out.println(bean);
    }

}
